<%@ page language="java" contentType="text/html; charset=US-ASCII"
    pageEncoding="US-ASCII"%>
<%@ page import="java.sql.*" %>
<%@ page import="ca.radiologydb.util.Template" %>
<%@ page import="ca.radiologydb.util.ConnectionManager" %>
<%@ page import="ca.radiologydb.util.DataAnalysis" %>

<%

	Template template = new Template(this.getServletContext().getRealPath("/").toString());
	out.println(template.getTemplateTop());
	

	// Check Permissions
	if (session.getAttribute("username") == null
			|| session.getAttribute("usertype") == null) {
		out.println("Cannot display results as you're not logged in, or do not have the proper permissions.");
		out.println("<a href='login.jsp'>Login</a>");
		
		//This page is only accessible to administrators
	} else if (!session.getAttribute("usertype").equals("a")) {
		out.println("Cannot display results as you're not logged in, or do not have the proper permissions.");
		out.println("<a href='login.jsp'>Login</a>");

		//Show the page if the user is an administrator
	} else {
	
		ConnectionManager manager = new ConnectionManager();
		Connection conn = manager.getConnection();
		
		out.println("<h3>Data Analysis Module</h3>");
		
		//Get report criteria
		out.println("<h4>Select Analysis Criteria</h4>");
		out.println("<form name='analysis_options' action='DataAnalysis' method='GET'>");
		out.println("<input type='checkbox' id='name' name='patient_name' /> Patient Name<br/>");
		out.println("<input type='checkbox' id='type' name='test_type' /> Test Type <br />");
		out.println("<input type='checkbox' id='date' name='test_date' /> Test Date <br />");
		out.println("<h4>Select Date Granularity</h4>");
		out.println("<select name='date_granularity' id='granularity'>");
		out.println("<option value='YYYY'>Year</option>");
		out.println("<option value='MM'>Month</option>");
		out.println("<option value='WW'>Week</option>");
		out.println("</select>");
		
		out.println("<input type='submit' value='Get Analysis' />");
		
		out.println("</form>");
		manager.closeConnection();
	}
	out.println(template.getTemplateBottom());

%>